<?php

namespace App\Http\Model;

use Illuminate\Support\Facades\DB;

class PropLog extends Base
{
    protected $table = 'prop_log';

    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    /**
     * 用户道具发放记录-创建
     *
     * @param array $data 数据
     * @param string $type 操作类型 默认 insert=创建，update=更新
     * @return bool
     * */
    public function updateOrInsertPropLog($data = [], $type = 'insert')
    {
        switch ($type) {
            case 'insert':
                $data['created_at'] = time();
                $ret = DB::table($this->table)->insertGetId($data);
                break;
            default:
                $ret = false;
                break;
        }

        return $ret;
    }
}